def sortColumns(matrix):
    if not matrix or not matrix[0]:
        return []
    rows = len(matrix)
    cols = len(matrix[0])
    result = [row[:] for row in matrix]
    for col in range(cols):
        column = [result[row][col] for row in range(rows)]
        column.sort()
        for row in range(rows):
            result[row][col] = column[row]
    return result

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===